//
// Created by mac on 1/26/22.
//

#include <string>
using namespace std;
string countAndSay(int n) {
    string curr("1");
    string prev;

    for (int i = 1; i < n; ++i) {
        prev= curr;
        curr="";
        //计算个数
        char ch = prev[0];
        int count = 1;
        for (int j = 1; j < prev.size(); ++j) {
            if(prev[j]==ch){
                count++;
            } else{
                curr+=to_string(count);
                curr+=ch;
                count=1;
                ch=prev[j];
            }
        }
      //别忘了最后一个
        curr+=to_string(count);
        curr+=ch;

    }
    return curr;

}